package co.fitstart.admin.dao;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dynamic;
import com.demo2do.core.persistence.annotation.Limit;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;

import co.fitstart.entity.user.StudentTargetData;
import co.fitstart.entity.user.User;
import co.fitstart.entity.user.UserTargetData;
import co.fitstart.entity.user.bwh.BwhRecord;
import co.fitstart.entity.user.investigation.FitInvestigation;
import co.fitstart.entity.user.investigation.HealthInvestigation;
import co.fitstart.entity.user.investigation.ParticipateInvestigation;

/**
 * 
 * @author lidan
 *
 */
@Dynamic("hibernate")
public interface UserDao {

    /**
     * 
     * @param beginIndex
     * @param maxResult
     * @return
     */
    @Limit
    @Query("FROM User WHERE disabled = false")
    public List<User> list(@Variable("beginIndex")int beginIndex, @Variable("maxResult") int maxResult);
    
    /**
     * 
     * @param beginIndex
     * @param maxResult
     * @return
     */
    @Limit
    @Query("SELECT round.user FROM MarketCourseRound round WHERE round.disabled = false")
    public List<User> listUser(@Variable("beginIndex")int beginIndex, @Variable("maxResult") int maxResult);
    
    /**
     * 
     * @param mobile
     * @return
     */
    @Query("FROM User WHERE disabled = false AND mobile = :mobile")
    public User load(@Variable("mobile") String mobile);
    
    /**
     * list userFitRecord by user
     * 
     * @param user
     * @return
     */
    @Query("FROM FitInvestigation WHERE user = :user")
    public List<FitInvestigation> listFitInvestigation(@Variable("user") User user);
    
    /**
     * 
     * @param user
     * @return
     */
    @Query("FROM UserTargetData WHERE user = :user")
    public List<UserTargetData> listUserTargetData(@Variable("user") User user);
    
    /**
     * list HealthInvestigation by user
     * 
     * @param user
     * @return
     */
    @Query("FROM HealthInvestigation WHERE user = :user")
    public HealthInvestigation loadHealthInvestigation(@Variable("user") User user);
    
    /**
     * list ParticipateInvestigation by user
     * 
     * @param user
     * @return
     */
    @Query("FROM ParticipateInvestigation WHERE user = :user")
    public ParticipateInvestigation loadParticipateInvestigation(@Variable("user") User user);
    
    /**
     * 
     * @param user
     * @return
     */
    @Query("FROM BwhRecord WHERE disabled = false AND user = :user ORDER BY createTime DESC")
    public List<BwhRecord> listBwhRecord(@Variable("user") User user);
    
    /**
     * 
     * @param user
     * @return
     */
    @Query("FROM StudentTargetData WHERE disabled = false AND student.user = :user ORDER BY createTime DESC")
    public List<StudentTargetData> listStudentTargetData(@Variable("user") User user);

}
